home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_46_select tool script.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  15.4 KB  |  214 lines

  1. global gCast, gSize, gVariable, gSecondColor, myCurrentImage, myCurrentSelection, myCurrentPreview, myTimerStart, gSelectRect, gMarqueeRect, gSelectionEdited, myStartImage
  2.  
  3. on toolSelect
  4.   startX = ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left
  5.   startY = ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top
  6.   repeat while the mouseDown
  7.     if ((((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left) = startX) and ((((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top) = startY) then
  8.       sprite(4).rect = rect(startX, startY, startX, startY)
  9.       sprite(5).rect = rect(startX, startY, startX, startY)
  10.       sprite(6).rect = rect(startX, startY, startX, startY)
  11.       sprite(7).rect = rect(startX, startY, startX, startY)
  12.     else
  13.       if ((((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left) < startX) and ((((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top) < startY) then
  14.         sprite(4).rect = rect(((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top, startX + gVariable, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + 1)
  15.         sprite(5).rect = rect(((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top, ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + 1, startY + gVariable)
  16.         sprite(6).rect = rect(startX + gVariable - 1, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top, startX + gVariable, startY + gVariable)
  17.         sprite(7).rect = rect(((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left, startY + gVariable - 1, startX + gVariable, startY + gVariable)
  18.       else
  19.         if ((((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left) > startX) and ((((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top) > startY) then
  20.           sprite(4).rect = rect(startX, startY, ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + gVariable, startY + 1)
  21.           sprite(5).rect = rect(startX, startY, startX + 1, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + gVariable)
  22.           sprite(6).rect = rect(((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + gVariable - 1, startY, ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + gVariable, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + gVariable)
  23.           sprite(7).rect = rect(startX, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + gVariable - 1, ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + gVariable, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + gVariable)
  24.         else
  25.           if ((((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left) >= startX) and ((((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top) <= startY) then
  26.             sprite(4).rect = rect(startX, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top, ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + gVariable, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + 1)
  27.             sprite(5).rect = rect(startX, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top, startX + 1, startY + gVariable)
  28.             sprite(6).rect = rect(((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + gVariable - 1, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top, ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + gVariable, startY + gVariable)
  29.             sprite(7).rect = rect(startX, startY + gVariable - 1, ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + gVariable, startY + gVariable)
  30.           else
  31.             if ((((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left) <= startX) and ((((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top) >= startY) then
  32.               sprite(4).rect = rect(((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left, startY, startX + gVariable, startY + 1)
  33.               sprite(5).rect = rect(((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left, startY, ((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left + 1, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + gVariable)
  34.               sprite(6).rect = rect(startX + gVariable - 1, startY, startX + gVariable, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + gVariable)
  35.               sprite(7).rect = rect(((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + gVariable - 1, startX + gVariable, ((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top + gVariable)
  36.             end if
  37.           end if
  38.         end if
  39.       end if
  40.       put sprite(4).width / gVariable into field "dimension status W"
  41.       put sprite(5).height / gVariable into field "dimension status H"
  42.     end if
  43.     updateStage()
  44.   end repeat
  45.   if ((((the mouseH - sprite(1).left) / gVariable * gVariable) + sprite(1).left) = startX) and ((((the mouseV - sprite(1).top) / gVariable * gVariable) + sprite(1).top) = startY) then
  46.     if gSelectionEdited = 1 then
  47.       sprite(35).pState = 0
  48.       sendSprite(35, #setMember)
  49.       member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  50.     end if
  51.     myStartImage = VOID
  52.     myCurrentImage = VOID
  53.     myCurrentPreview = VOID
  54.     myCurrentSelection = VOID
  55.     myTimerStart = 0
  56.     gSelectionEdited = VOID
  57.     gMarqueeRect = rect(0, 0, 0, 0)
  58.     gSelectRect = rect(0, 0, 0, 0)
  59.     sprite(4).rect = rect(800, 600, 810, 610)
  60.     sprite(5).rect = rect(800, 600, 810, 610)
  61.     sprite(6).rect = rect(800, 600, 810, 610)
  62.     sprite(7).rect = rect(800, 600, 810, 610)
  63.     put EMPTY into field "dimension status W"
  64.     put EMPTY into field "dimension status H"
  65.     updateStage()
  66.     pass()
  67.   else
  68.     if (sprite(4).top < sprite(1).top) and (sprite(6).right > sprite(1).right) then
  69.       sprite(4).rect = rect(sprite(4).left, sprite(1).top, sprite(1).right, sprite(1).top + 1)
  70.       sprite(5).rect = rect(sprite(5).left, sprite(1).top, sprite(5).right, sprite(5).bottom)
  71.       sprite(6).rect = rect(sprite(1).right - 1, sprite(1).top, sprite(1).right, sprite(6).bottom)
  72.       sprite(7).rect = rect(sprite(7).left, sprite(7).top, sprite(1).right, sprite(7).bottom)
  73.     else
  74.       if (sprite(7).bottom > sprite(1).bottom) and (sprite(6).right > sprite(1).right) then
  75.         sprite(4).rect = rect(sprite(4).left, sprite(4).top, sprite(1).right, sprite(4).bottom)
  76.         sprite(5).rect = rect(sprite(5).left, sprite(5).top, sprite(5).right, sprite(1).bottom)
  77.         sprite(6).rect = rect(sprite(1).right - 1, sprite(6).top, sprite(1).right, sprite(1).bottom)
  78.         sprite(7).rect = rect(sprite(7).left, sprite(1).bottom - 1, sprite(1).right, sprite(1).bottom)
  79.       else
  80.         if (sprite(4).top < sprite(1).top) and (sprite(5).left < sprite(1).left) then
  81.           sprite(4).rect = rect(sprite(1).left, sprite(1).top, sprite(4).right, sprite(1).top + 1)
  82.           sprite(5).rect = rect(sprite(1).left, sprite(1).top, sprite(1).left + 1, sprite(5).bottom)
  83.           sprite(6).rect = rect(sprite(6).left, sprite(1).top, sprite(6).right, sprite(6).bottom)
  84.           sprite(7).rect = rect(sprite(1).left, sprite(7).top, sprite(7).right, sprite(7).bottom)
  85.         else
  86.           if (sprite(7).bottom > sprite(1).bottom) and (sprite(5).left < sprite(1).left) then
  87.             sprite(4).rect = rect(sprite(1).left, sprite(4).top, sprite(4).right, sprite(4).bottom)
  88.             sprite(5).rect = rect(sprite(1).left, sprite(5).top, sprite(1).left + 1, sprite(1).bottom)
  89.             sprite(6).rect = rect(sprite(6).left, sprite(6).top, sprite(6).right, sprite(1).bottom)
  90.             sprite(7).rect = rect(sprite(1).left, sprite(1).bottom - 1, sprite(7).right, sprite(1).bottom)
  91.           else
  92.             if sprite(4).top < sprite(1).top then
  93.               sprite(4).rect = rect(sprite(4).left, sprite(1).top, sprite(4).right, sprite(1).top + 1)
  94.               sprite(5).rect = rect(sprite(5).left, sprite(1).top, sprite(5).right, sprite(5).bottom)
  95.               sprite(6).rect = rect(sprite(6).left, sprite(1).top, sprite(6).right, sprite(6).bottom)
  96.             else
  97.               if sprite(6).right > sprite(1).right then
  98.                 sprite(4).rect = rect(sprite(4).left, sprite(4).top, sprite(1).right, sprite(4).bottom)
  99.                 sprite(6).rect = rect(sprite(1).right - 1, sprite(6).top, sprite(1).right, sprite(6).bottom)
  100.                 sprite(7).rect = rect(sprite(7).left, sprite(7).top, sprite(1).right, sprite(7).bottom)
  101.               else
  102.                 if sprite(7).bottom > sprite(1).bottom then
  103.                   sprite(5).rect = rect(sprite(5).left, sprite(5).top, sprite(5).right, sprite(1).bottom)
  104.                   sprite(6).rect = rect(sprite(6).left, sprite(6).top, sprite(6).right, sprite(1).bottom)
  105.                   sprite(7).rect = rect(sprite(7).left, sprite(1).bottom - 1, sprite(7).right, sprite(1).bottom)
  106.                 else
  107.                   if sprite(5).left < sprite(1).left then
  108.                     sprite(4).rect = rect(sprite(1).left, sprite(4).top, sprite(4).right, sprite(4).bottom)
  109.                     sprite(5).rect = rect(sprite(1).left, sprite(5).top, sprite(1).left + 1, sprite(5).bottom)
  110.                     sprite(7).rect = rect(sprite(1).left, sprite(7).top, sprite(7).right, sprite(7).bottom)
  111.                   end if
  112.                 end if
  113.               end if
  114.             end if
  115.           end if
  116.         end if
  117.       end if
  118.     end if
  119.     put sprite(4).width / gVariable into field "dimension status W"
  120.     put sprite(5).height / gVariable into field "dimension status H"
  121.     updateStage()
  122.     if gSelectionEdited = 1 then
  123.       sprite(35).pState = 0
  124.       sendSprite(35, #setMember)
  125.       member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  126.     end if
  127.     gMarqueeRect = rect(sprite(5).left, sprite(4).top, sprite(6).right, sprite(7).bottom)
  128.     gSelectRect = rect((sprite(5).left - sprite(1).left) / gVariable, (sprite(4).top - sprite(1).top) / gVariable, (sprite(6).right - sprite(1).left) / gVariable, (sprite(7).bottom - sprite(1).top) / gVariable)
  129.     myTimerStart = the milliSeconds
  130.     gSelectionEdited = 0
  131.     myStartImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  132.     myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  133.     myCurrentPreview = duplicate(member("preview", gCast).image)
  134.     myCurrentSelection = image(gSelectRect.width, gSelectRect.height, member(gSize & "x" & gSize, gCast).depth, member(gSize & "x" & gSize, gCast).paletteRef)
  135.     if (myCurrentSelection = VOID) or (gSelectRect.width <= 0) or (gSelectRect.height <= 0) or (sprite(4).top <> sprite(5).top) or (sprite(7).bottom <> sprite(6).bottom) or (sprite(4).width <> sprite(7).width) or (sprite(5).height <> sprite(6).height) then
  136.       myStartImage = VOID
  137.       myCurrentImage = VOID
  138.       myCurrentPreview = VOID
  139.       myCurrentSelection = VOID
  140.       myTimerStart = 0
  141.       gSelectionEdited = VOID
  142.       gMarqueeRect = rect(0, 0, 0, 0)
  143.       gSelectRect = rect(0, 0, 0, 0)
  144.       sprite(4).rect = rect(800, 600, 810, 610)
  145.       sprite(5).rect = rect(800, 600, 810, 610)
  146.       sprite(6).rect = rect(800, 600, 810, 610)
  147.       sprite(7).rect = rect(800, 600, 810, 610)
  148.       put EMPTY into field "dimension status W"
  149.       put EMPTY into field "dimension status H"
  150.       updateStage()
  151.     else
  152.       myCurrentSelection.copyPixels(member(gSize & "x" & gSize, gCast).image, myCurrentSelection.rect, gSelectRect)
  153.     end if
  154.   end if
  155. end
  156.  
  157. on moveSelect
  158.   moverX = (the mouseH - sprite(1).left) / gVariable
  159.   moverY = (the mouseV - sprite(1).top) / gVariable
  160.   if gSelectionEdited = 0 then
  161.     if the shiftDown <> 1 then
  162.       myStartImage.fill(gSelectRect, gSecondColor)
  163.     end if
  164.     member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  165.   end if
  166.   repeat while the mouseDown
  167.     selectXDistance = ((the mouseH - sprite(1).left) / gVariable) - moverX
  168.     selectYDistance = ((the mouseV - sprite(1).top) / gVariable) - moverY
  169.     myCurrentImage.copyPixels(myStartImage, myCurrentImage.rect, myStartImage.rect)
  170.     gSelDestRect = rect(gSelectRect[1] + selectXDistance, gSelectRect[2] + selectYDistance, gSelectRect[3] + selectXDistance, gSelectRect[4] + selectYDistance)
  171.     sprite(4).rect = rect((gSelDestRect.left * gVariable) + sprite(1).left, (gSelDestRect.top * gVariable) + sprite(1).top, (gSelDestRect.right * gVariable) + sprite(1).left, (gSelDestRect.top * gVariable) + sprite(1).top + 1)
  172.     sprite(5).rect = rect((gSelDestRect.left * gVariable) + sprite(1).left, (gSelDestRect.top * gVariable) + sprite(1).top, (gSelDestRect.left * gVariable) + sprite(1).left + 1, (gSelDestRect.bottom * gVariable) + sprite(1).top)
  173.     sprite(6).rect = rect((gSelDestRect.right * gVariable) + sprite(1).left - 1, (gSelDestRect.top * gVariable) + sprite(1).top, (gSelDestRect.right * gVariable) + sprite(1).left, (gSelDestRect.bottom * gVariable) + sprite(1).top)
  174.     sprite(7).rect = rect((gSelDestRect.left * gVariable) + sprite(1).left, (gSelDestRect.bottom * gVariable) + sprite(1).top - 1, (gSelDestRect.right * gVariable) + sprite(1).left, (gSelDestRect.bottom * gVariable) + sprite(1).top)
  175.     myCurrentImage.copyPixels(myCurrentSelection, gSelDestRect, myCurrentSelection.rect)
  176.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  177.     updateStage()
  178.     fnUpdatePreview()
  179.   end repeat
  180.   tL = point(sprite(4).left + 1, sprite(4).top + 1)
  181.   tR = point(sprite(4).right - 1, sprite(4).top + 1)
  182.   bL = point(sprite(7).left + 1, sprite(7).bottom - 1)
  183.   bR = point(sprite(7).right - 1, sprite(7).bottom - 1)
  184.   if not inside(tL, sprite(1).rect) and not inside(tR, sprite(1).rect) and not inside(bL, sprite(1).rect) and not inside(bR, sprite(1).rect) and (sprite(1).rect.intersect(rect(tL[1], tL[2], bR[1], bR[2])) = rect(0, 0, 0, 0)) then
  185.     myCurrentImage.copyPixels(myStartImage, myCurrentImage.rect, myStartImage.rect)
  186.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  187.     sprite(4).rect = rect(800, 600, 810, 610)
  188.     sprite(5).rect = rect(800, 600, 810, 610)
  189.     sprite(6).rect = rect(800, 600, 810, 610)
  190.     sprite(7).rect = rect(800, 600, 810, 610)
  191.     put EMPTY into field "dimension status W"
  192.     put EMPTY into field "dimension status H"
  193.     updateStage()
  194.     fnUpdatePreview()
  195.     sprite(35).pState = 0
  196.     sendSprite(35, #setMember)
  197.     member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  198.     myTimerStart = 0
  199.     gSelectionEdited = VOID
  200.     gMarqueeRect = rect(0, 0, 0, 0)
  201.     gSelectRect = rect(0, 0, 0, 0)
  202.     myStartImage = VOID
  203.     myCurrentImage = VOID
  204.     myCurrentPreview = VOID
  205.     myCurrentSelection = VOID
  206.   else
  207.     gSelectionEdited = 1
  208.     gMarqueeRect = rect(sprite(5).left, sprite(4).top, sprite(6).right, sprite(7).bottom)
  209.     gSelectRect = rect((sprite(5).left - sprite(1).left) / gVariable, (sprite(4).top - sprite(1).top) / gVariable, (sprite(6).right - sprite(1).left) / gVariable, (sprite(7).bottom - sprite(1).top) / gVariable)
  210.     put gSelectRect.width into field "dimension status W"
  211.     put gSelectRect.height into field "dimension status H"
  212.   end if
  213. end
  214.